package test.ych.com.test

import android.support.test.espresso.Espresso.onView
import android.support.test.espresso.action.ViewActions.*
import android.support.test.espresso.assertion.ViewAssertions.matches
import android.support.test.espresso.matcher.ViewMatchers.withId
import android.support.test.espresso.matcher.ViewMatchers.withText
import android.support.test.rule.ActivityTestRule
import org.junit.Rule
import org.junit.Test

class MainActivityTest{
    val peter = "Peter"

    @Rule
    val mActivityRules = ActivityTestRule(MainActivity::class.java)

    @Test
    fun test(){
        //在输入框驶入peter
        onView(withId(R.id.et)).perform(typeText(peter), closeSoftKeyboard())
        //点击指定ID的Button
        onView(withId(R.id.btn)).perform(click())
        var str = "Hello,$peter ! "
        //将tv上的内容与str比较
        onView(withId(R.id.tv)).check(matches(withText(str)))
    }


}